<script setup >
import { ref, watch } from 'vue';
import { useRouter} from 'vue-router';

const props = defineProps(['routes'])
const router = useRouter()
const currentRoutePath = ref(router.currentRoute.value.path);

watch(router.currentRoute, (newCurrentRoute) => {
    currentRoutePath.value = newCurrentRoute.fullPath
})

function goTo(to) {
    router.push({path: to.path});
}

</script>

<template>
    <div class="sidebar">
        <button type="button" v-for="(r, index) in props.routes" :key="index" @click="goTo(r)" :class="{active: currentRoutePath.includes(r.path) }" >{{$t(`aside.${r.name}`)}}</button>
        <img src="/src/assets/images/student/TechLife-RemoteLife.svg" alt="Sidebar photo">
    </div>
</template>

<style scoped>

.sidebar {
    background-color: #dbdde3;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    z-index: 1;
    padding-top: 15px;
    position: relative;
}

.sidebar button {
    border: none;
    outline: none;
    cursor: pointer;
    width: 100%;
    height: 64px;
    font-family: Source Han Sans CN;
    font-size: 20px;
    line-height: 64px;
    text-align: center;
    color: #707070;
    background-color: transparent;
    opacity: 1;
}

.sidebar button:hover{
    opacity: 0.8;
    background-color: #ffffff;
}

.sidebar .active {
    box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.16);
    background-color: #ffffff;
}

.sidebar img {
    width: 100%;
    position: absolute;
    bottom: 39px;
    left: 0;
    
}

</style>